package com.yue;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;

@WebServlet("/test01")
public class Test01 extends HttpServlet {
    @Override
    public void init() throws ServletException {
        System.out.println("初始话开始了");
    }

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("请求进来了");
//        System.out.println(req.getMethod());
//        System.out.println(req.getRequestURL());
//        System.out.println(req.getScheme());
//        System.out.println(req.getServerName());
//        System.out.println(req.getServerPort());
//        System.out.println(req.getContextPath());
//        System.out.println(req.getQueryString());

        //获取所有的key
        Enumeration<String> keys = req.getHeaderNames();
//        while(keys.hasMoreElements()){
////            String key = keys.nextElement();
////            System.out.println(key+"==="+req.getHeader(key));
////        }
//        String n = req.getParameter("n");
//        System.out.println(n);
//        String n1 = req.getParameter("n1");
//        System.out.println(n1);
//        String uname = req.getParameter("uname");
//        System.out.println(uname);
//        String uname1 = req.getParameter("uname1");
//        System.out.println(uname1);
        req.setCharacterEncoding("utf-8");
        String accound = req.getParameter("accound");
        System.out.println(accound);
        String pwd = req.getParameter("pwd");
        System.out.println(pwd);

    }

    @Override
    public void destroy() {
        System.out.println("销毁了");
    }
}
